﻿@{Layout = "~/Views/Shared/_Layout.cshtml";}
@model IEnumerable<Scheduling.Models.Room>
<h1>Rooms</h1>
 <br />@Html.ActionLink("Add Room", "Add")
<form method="post">
    <table>
        <tr>
            <td>Room: </td>
            <td><input type="text" name="inSearchRoomPattern" value="@ViewData["inSearchRoomPattern"]" /></td>
        </tr>
        <tr>
            <td colspan="2"><input type="submit" value="Search" /></td>
        </tr>
    </table>
   
</form>
<h2>Search Results</h2>
<p class="BodyText">For search query: <em>'@ViewData["inSearchRoomPattern"]'</em></p>
@if(Model.Count() > 0)
{

<table class="Table" cellspacing="0">
    <tr>
        <th>Room</th>
        <th>Name</th>
        <th>Capacity</th>
        <th>Description</th>
        <th></th>
    </tr>
   
    @{foreach (var room in Model)
      {
        <tr onclick="location.href='@Href("~/Room/Show/" + room.ID)'" class="Clickable">
            <td style="width:70px;">
                @room.ID
            </td>  
            <td style="width:200px;">
                @room.Name
            </td>  
            <td style="width:80px;">
                @room.Capacity
            </td>  
            <td>
                @room.Description
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = room.ID })
            </td>
            <td>
                @Html.ActionLink("Delete", "Delete", new { id = room.ID})
            </td>
        </tr>
      }
    }
    
    </table>
}
else if (ViewData["inSearchRoomPattern"] == null && Model.Count() == 0)
{
    <p>Please enter a search query. </p>
}
else
{
    <p>No Search Results... </p>
}
